<p><a href="#root/_help_CdNpE2pqjmI6">Script</a> notes can be triggered by
  events. Note that these are backend events and thus relation need to point
  to the "JS backend" code note.</p>
<h2>Global events</h2>
<p>Global events are attached to the script note via label. Simply create
  e.g. "run" label with some of these values and script note will be executed
  once the event occurs.</p>
<table>
  <thead>
    <tr>
      <th>Label</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>run</code>
      </td>
      <td>
        <p>Defines on which events script should run. Possible values are:</p>
        <ul>
          <li><code>frontendStartup</code> - when Trilium frontend starts up (or is refreshed),
            but not on mobile.</li>
          <li><code>mobileStartup</code> - when Trilium frontend starts up (or is refreshed),
            on mobile.</li>
          <li><code>backendStartup</code> - when Trilium backend starts up</li>
          <li><code>hourly</code> - run once an hour. You can use additional label <code>runAtHour</code> to
            specify at which hour, on the back-end.</li>
          <li><code>daily</code> - run once a day, on the back-end</li>
        </ul>
      </td>
    </tr>
    <tr>
      <td><code>runOnInstance</code>
      </td>
      <td>Specifies that the script should only run on a particular&nbsp;<a class="reference-link"
        href="#root/_help_c5xB8m4g2IY6">Trilium instance</a>.</td>
    </tr>
    <tr>
      <td><code>runAtHour</code>
      </td>
      <td>On which hour should this run. Should be used together with <code>#run=hourly</code>.
        Can be defined multiple times for more runs during the day.</td>
    </tr>
  </tbody>
</table>

<h2>Entity events</h2>
<p>Other events are bound to some entity, these are defined as <a href="#root/_help_zEY4DaJG4YT5">relations</a> -
  meaning that script is triggered only if note has this script attached
  to it through relations (or it can inherit it).</p>
<table>
  <thead>
    <tr>
      <th>Relation</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>runOnNoteCreation</code>
      </td>
      <td>executes when note is created on backend. Use this relation if you want
        to run the script for all notes created under a specific subtree. In that
        case, create it on the subtree root note and make it inheritable. A new
        note created within the subtree (any depth) will trigger the script.</td>
    </tr>
    <tr>
      <td><code>runOnChildNoteCreation</code>
      </td>
      <td>executes when new note is created under the note where this relation is
        defined</td>
    </tr>
    <tr>
      <td><code>runOnNoteTitleChange</code>
      </td>
      <td>executes when note title is changed (includes note creation as well)</td>
    </tr>
    <tr>
      <td><code>runOnNoteContentChange</code>
      </td>
      <td>executes when note content is changed (includes note creation as well).</td>
    </tr>
    <tr>
      <td><code>runOnNoteChange</code>
      </td>
      <td>executes when note is changed (includes note creation as well). Does not
        include content changes</td>
    </tr>
    <tr>
      <td><code>runOnNoteDeletion</code>
      </td>
      <td>executes when note is being deleted</td>
    </tr>
    <tr>
      <td><code>runOnBranchCreation</code>
      </td>
      <td>executes when a branch is created. Branch is a link between parent note
        and child note and is created e.g. when cloning or moving note.</td>
    </tr>
    <tr>
      <td><code>runOnBranchChange</code>
      </td>
      <td>executes when a branch is updated. (since v0.62)</td>
    </tr>
    <tr>
      <td><code>runOnBranchDeletion</code>
      </td>
      <td>executes when a branch is deleted. Branch is a link between parent note
        and child note and is deleted e.g. when moving note (old branch/link is
        deleted).</td>
    </tr>
    <tr>
      <td><code>runOnAttributeCreation</code>
      </td>
      <td>executes when new attribute is created for the note which defines this
        relation</td>
    </tr>
    <tr>
      <td><code>runOnAttributeChange</code>
      </td>
      <td>executes when the attribute is changed of a note which defines this relation.
        This is triggered also when the attribute is deleted</td>
    </tr>
  </tbody>
</table>